﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;
using BL;

namespace WebsiteBanHang
{
    public partial class QLyDonHang : System.Web.UI.Page
    {
        DonDatHangBL donHang = new DonDatHangBL();
        DonDatHangDAL dh = new DonDatHangDAL();
        List<DonDatHangDAL> dsDonHang = new List<DonDatHangDAL>();
        protected void Page_Load(object sender, EventArgs e)
        {


        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (rdiXemTatCa.Checked == true)
            {
                dsDonHang = donHang.LayDSDonHang();

            }
            if (rdiXemTheoTinhTrang.Checked == true)
            {
                if (ddlTinhTrang.SelectedValue == "0")
                    dsDonHang = donHang.LayDSDonHangTheoTrangThai(true);
                if (ddlTinhTrang.SelectedValue == "1")
                    dsDonHang = donHang.LayDSDonHangTheoTrangThai(false);
                if (ddlTinhTrang.SelectedValue == "2")
                    dsDonHang = donHang.LayDSDonHangTheoTrangThai(false);

            }


            GridView1.DataSource = dsDonHang;
            GridView1.DataBind();

        }
        protected void lbt_ChiTiet_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                GridViewRow row = GridView1.Rows[i];
                bool isChecked = ((CheckBox)row.Cells[0].FindControl("cbRows")).Checked;
                if (isChecked)
                {
                    TableCell madonhang = GridView1.Rows[i].Cells[2];
                    TableCell taikhoan = GridView1.Rows[i].Cells[3];
                    string url = "";
                    url = "SuaUser.aspx?madonhang=" + madonhang.Text + "&taikhoan=" + taikhoan.Text;
                    Response.Redirect(url);
                }
            }

        }
    }
}